﻿
@{
    Layout = null;
}


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>集成电路封装</legend>
            </fieldset>

            <form class="layui-form" action="" lay-filter="example">
                <input type="hidden" name="ID" value="0" />
                <input type="hidden" name="SourceGoodsID" value="" id="SourceGoodsID" />
                <input type="hidden" name="BillID" value="" id="BillID" />
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" onclick="ShowSelectGoods('sg')" type="button">选择源料</button>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SourceGoodsName" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsName" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">型号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SourceGoodsModel" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsModel" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">比例数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Qty" lay-verify="required|number" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">领料数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="LingQty" lay-verify="required|number" autocomplete="off" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">货源号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="HuoYuanHao" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">检验批号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="JianYanPiHao" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">制造厂商</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ZhiZhaoChangShang" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">芯片面积</label>
                        <div class="layui-input-inline">
                            <input type="text" name="XinPianMianJi" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">正面金属</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ZhengMianJinShu" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">背面金属</label>
                        <div class="layui-input-inline">
                            <input type="text" name="BeiMianJinShu" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">源料类型</label>
                    <div class="layui-input-block">
                        <select name="Type" lay-search id="Type">
                            <option value="1">管座</option>
                            <option value="2">管帽</option>
                            <option value="3">芯片</option>
                        </select>
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="~/layui/layui.js"></script>
    <script src="~/scripts/jquery-1.4.4.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['form', 'layedit', 'laydate', 'jquery'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , $ = layui.jquery
            //日期

            form.on('submit(demo1)', function (data) {
                if (data.field.Qty <= 0) {
                    layer.alert('比例数必须大于等于0', { icon: 5 });
                    return false;
                }
                $.ajax({
                    url: '@Url.Action("BillBOMDetailsEditAsync", "Bill6")',
                    type: 'post',
                    dataType: 'json',
                    data: data.field,
                    success: function (data) {
                        console.log(data);
                        //Info,Success,Warning,Error
                        var type = data.Type;
                        if (type == 1) {
                            layer.msg(data.Content, { icon: 6, time: 2000 },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });

                        } else {
                            layer.alert(data.Content, { icon: 5 });
                        }
                    }
                });
                //layer.alert(JSON.stringify(data.field), {
                //    title: '最终的提交信息'
                //})
                return false;
            });
            //表单初始赋值
            form.val('example', {
                "ID": "@ViewBag.model.ID"
                , "BillID": "@ViewBag.model.BillID"
                , "SourceGoodsID": "@ViewBag.model.SourceGoodsID"
                , "SourceGoodsName": "@ViewBag.model.SourceGoodsName"
                , "SourceGoodsModel": "@ViewBag.model.SourceGoodsModel"
                , "Qty": "@ViewBag.model.Qty"
                , "LingQty": "@ViewBag.model.LingQty"
                , "Type": "@ViewBag.model.Type"
                , "HuoYuanHao": "@ViewBag.model.HuoYuanHao"
                , "JianYanPiHao": "@ViewBag.model.JianYanPiHao"
                , "ZhiZhaoChangShang": "@ViewBag.model.ZhiZhaoChangShang"
                , "XinPianMianJi": "@ViewBag.model.XinPianMianJi"
                , "ZhengMianJinShu": "@ViewBag.model.ZhengMianJinShu"
                , "BeiMianJinShu": "@ViewBag.model.BeiMianJinShu"
            })


        });
        function ShowSelectGoods(back) {
            var index = layer.open({
                title: '选择产品',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: false,
                area: ['800px', '400px'],
                content: '@Url.Action("GoodsSelect", "BasicInfo")' + '?Back=' + back + '&TypeID=1&BillNameID=3',
            });
            layer.full(index);
            return false;
        }
        function selectgoods(id, code, name, model, back) {
            if (back == 'g') {
                $('#GoodsID').val(id);
                $('#GoodsName').val(name);
                $('#GoodsModel').val(model);
            }
            if (back == 'sg') {
                $('#SourceGoodsID').val(id);
                $('#SourceGoodsName').val(name);
                $('#SourceGoodsModel').val(model);
            }
        }
    </script>

</body>
</html>